﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.PLCRecorderModes.CUIPlcRecorderModesForm
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.PrivateImplementationDetails;
using Tecnomatix.Engineering.Ui;


namespace DnProcessSimulateCommands.PLCRecorderModes;

public class CUIPlcRecorderModesForm : TxForm
{
  private IContainer components;
  private GroupBox groupBox1;
  private RadioButton radioButton3;
  private RadioButton radioButton2;
  private Button button1;

  public CUIPlcRecorderModesForm()
  {
    this.InitializeComponent();
    this.Init();
  }

  private void Init()
  {
    if (!TxFeatureManager.CheckFeature("PLC_RECORDER"))
    {
      this.radioButton2.Enabled = false;
      this.radioButton3.Enabled = false;
    }
    else
    {
      switch (TxApplication.Options.Units.LinearDigitsAfterDecimalPoint)
      {
        case 8:
          this.radioButton2.Checked = true;
          break;
        case 9:
          this.radioButton3.Checked = true;
          break;
      }
    }
  }

  private void UpdateMode()
  {
    if (this.radioButton2.Checked)
    {
      TxApplication.Options.Units.LinearDigitsAfterDecimalPoint = 8;
    }
    else
    {
      if (!this.radioButton3.Checked)
        return;
      TxApplication.Options.Units.LinearDigitsAfterDecimalPoint = 9;
    }
  }

  private void setPLCRecorderModeToDefault()
  {
    TxApplication.Options.Units.LinearDigitsAfterDecimalPoint = 7;
  }

  private void OnCancel(object sender, EventArgs e) => ((Form) this).Close();

  protected virtual void OnClosing(CancelEventArgs e) => this.setPLCRecorderModeToDefault();

  private void radioButton2_CheckedChanged(object sender, EventArgs e) => this.UpdateMode();

  private void radioButton3_CheckedChanged(object sender, EventArgs e) => this.UpdateMode();

  protected virtual void Dispose(bool disposing)
  {
    if (disposing && this.components != null)
      this.components.Dispose();
    base.Dispose(disposing);
  }

  private void InitializeComponent()
  {
    this.groupBox1 = new GroupBox();
    this.radioButton3 = new RadioButton();
    this.radioButton2 = new RadioButton();
    this.button1 = new Button();
    this.groupBox1.SuspendLayout();
    ((Control) this).SuspendLayout();
    this.groupBox1.Controls.Add((Control) this.radioButton3);
    this.groupBox1.Controls.Add((Control) this.radioButton2);
    this.groupBox1.Location = new Point(16 /*0x10*/, 15);
    this.groupBox1.Margin = new Padding(4, 4, 4, 4);
    this.groupBox1.Name = "groupBox1";
    this.groupBox1.Padding = new Padding(4, 4, 4, 4);
    this.groupBox1.Size = new Size(187, 84);
    this.groupBox1.TabIndex = 0;
    this.groupBox1.TabStop = false;
    this.groupBox1.Text = "Select Recorder Mode:";
    this.radioButton3.AutoSize = true;
    this.radioButton3.Location = new Point(9, 52);
    this.radioButton3.Margin = new Padding(4, 4, 4, 4);
    this.radioButton3.Name = "radioButton3";
    this.radioButton3.Size = new Size(86, 21);
    this.radioButton3.TabIndex = 2;
    this.radioButton3.TabStop = true;
    this.radioButton3.Text = "Playback";
    this.radioButton3.UseVisualStyleBackColor = true;
    this.radioButton3.CheckedChanged += new EventHandler(this.radioButton3_CheckedChanged);
    this.radioButton2.AutoSize = true;
    this.radioButton2.Location = new Point(9, 22);
    this.radioButton2.Margin = new Padding(4, 4, 4, 4);
    this.radioButton2.Name = "radioButton2";
    this.radioButton2.Size = new Size(75, 21);
    this.radioButton2.TabIndex = 1;
    this.radioButton2.TabStop = true;
    this.radioButton2.Text = "Record";
    this.radioButton2.UseVisualStyleBackColor = true;
    this.radioButton2.CheckedChanged += new EventHandler(this.radioButton2_CheckedChanged);
    this.button1.DialogResult = DialogResult.Cancel;
    this.button1.Location = new Point(103, 106);
    this.button1.Margin = new Padding(4, 4, 4, 4);
    this.button1.Name = "button1";
    this.button1.Size = new Size(100, 28);
    this.button1.TabIndex = 1;
    this.button1.Text = "Cancel";
    this.button1.UseVisualStyleBackColor = true;
    this.button1.Click += new EventHandler(this.OnCancel);
    ((ContainerControl) this).AutoScaleDimensions = new SizeF(8f, 16f);
    ((ContainerControl) this).AutoScaleMode = AutoScaleMode.Font;
    ((Form) this).CancelButton = (IButtonControl) this.button1;
    ((Form) this).ClientSize = new Size(213, 149);
    ((Control) this).Controls.Add((Control) this.button1);
    ((Control) this).Controls.Add((Control) this.groupBox1);
    ((Form) this).FormBorderStyle = FormBorderStyle.FixedDialog;
    ((Form) this).Margin = new Padding(4, 4, 4, 4);
    ((Form) this).MaximizeBox = false;
    ((Form) this).MinimizeBox = false;
    ((Control) this).Name = nameof (CUIPlcRecorderModesForm);
    this.ShouldCloseOnDocumentUnloading = true;
    ((Form) this).ShowIcon = false;
    ((Control) this).Text = "PLC Recorder Modes";
    this.groupBox1.ResumeLayout(false);
    this.groupBox1.PerformLayout();
    ((Control) this).ResumeLayout(false);
  }
}
